﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;

namespace GWEB.WebFrame.Models
{
    public class Distribution
    {
        public PageInfo Init()
        {            
            PageInfo pg = new PageInfo();
            HttpSessionState session =System.Web.HttpContext.Current.Session;
            pg.dict = BasePage.getDict(session);
            pg.Type = "Distribution";
            pg.SMenuId = "KH";
            pg.TableName = "cu_Customers";
            pg.KeyFieldName = "id";
            pg.Sop = BasePage.Grant(session, pg.SMenuId);

            pg.Sop.ADD = false;pg.Sop.EDIT = false; pg.Sop.DEL = false;
            HttpRequest request = System.Web.HttpContext.Current.Request;
            String Ids = request["Ids"];
            String KeyCodes = request["KeyCodes"];
            pg.Sql = String.Format(@"
select * from (
select iuserid as id,sshowname,0 AgentCount,'' link
from tb_sys_users where UserType=1
) tb_sys_users where 1=1 ");
            ColumnInfo cl;
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "sshowname"; cl.HeadText = "顾问"; cl.IsCondition = true;cl.ConditionPosition = 1; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Decimal; cl.FieldName = "AgentCount"; cl.HeadText = "分配数量"; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.DataType = Tag.Text; cl.FieldName = "link"; cl.HeadText = "操作"; cl.IsSort = false; cl.Script = "<a href=\"javascript: Do('',{ id:[id],keyCode: GetKeyCode('[id]'),Ids:'"+ Ids + "',KeyCodes:'"+ KeyCodes + "'})\" class='layui-btn layui-btn-xs'>分配</a>"; pg.AddColumn(cl);
            return pg;
        }
    }
}